package cn.bravolinks.tools.service.Impl;

import cn.bravolinks.tools.dao.UserDao;
import cn.bravolinks.tools.domain.User;
import cn.bravolinks.tools.service.UserService;
import cn.bravolinks.tools.utils.CommonUtil;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Created by yanqin on 2017/6/4.
 */
@Service
public class UserImpl  implements UserService{

    @Autowired
    private UserDao userDao;

    /**
     * 查询有没有这个userid的用户
     *
     * @param userid
     * @return
     */
    @Override
    public Integer getByuserid(String userid) {
        return userDao.getByuserid(userid);
    }

    /**
     * 登录
     *
     * @param userid
     * @param password
     * @return
     */
    @Override
    public User getLogin(String userid, String password) {
        return userDao.getLogin(userid,CommonUtil.md5Base64("moon"+password));
    }

    /**
     * 添加一条记录
     *
     * @param user
     */
    @Override
    public int insert(User user) {
        user.setPassword(CommonUtil.md5Base64("moon"+user.getPassword()));
        return userDao.insert(user);
    }
    /**
     * 查询所有
     *
     * @param user
     */
	@Override
	public List<User> queryUser() {
		
		return userDao.queryUser();
	}

	@Override
	public List<User> queryUserByType(String type) {
		return userDao.queryUserByType(type);
	}
}
